home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / dev / c / EasygadgetsSou.lha / EasyGadgets / EasyGadgets.h < prev    next >
C/C++ Source or Header  |  1995-11-24  |  10KB  |  336 lines

  1. /*
  2.  *    File:                    EasyGadgets.h
  3.  *    Description:    
  4.  *
  5.  *    (C) 1994,1995, Ketil Hunn
  6.  *
  7.  */
  8.  
  9. #ifndef LIBRARIES_EASYGADGETS_H
  10. #define LIBRARIES_EASYGADGETS_H
  11.  
  12. /*** PRIVATE INCLUDES ****************************************************************/
  13. #ifndef LIBRARIES_GADTOOLS_H
  14. #include <libraries/gadtools.h>
  15. #endif
  16.  
  17. #ifndef INTUITION_GADGETCLASS_H
  18. #include <intuition/gadgetclass.h>
  19. #endif
  20.  
  21. #ifndef CLIB_EASYGADGETS_PROTOS_H
  22. #include <clib/easygadgets_protos.h>
  23. #endif
  24.  
  25. #ifndef CLIB_AMIGAGUIDE_PROTOS_H
  26. #include <clib/amigaguide_protos.h>
  27. #endif
  28.  
  29. #include <intuition/icclass.h>
  30. #include <intuition/classes.h>
  31. #include <graphics/text.h>
  32. #include <graphics/gfxmacros.h>
  33.  
  34. /*** DEFINES *************************************************************************/
  35.  
  36. #define    EASYGADGETSNAME                        "easygadgets.library"
  37. #define    EASYGADGETSVERSION                2L
  38.  
  39. //#define NM_IGNORE    64
  40.  
  41. /*** MACROS **************************************************************************/
  42. #define    egActivateGadget(g,w,r)        ActivateGadget((g)->gadget, w, r);
  43. #define    egTaskActive(t)                        ((t)->status)
  44. #define    egActivateTask(t)                    ((t)->status=STATUS_OPEN)
  45.  
  46. #define    DetachList(g,w)                        egSetGadgetAttrs(g, w, NULL, GTLV_Labels,~0,TAG_END)
  47. #define    AttachList(g,w,l)                    egSetGadgetAttrs(g, w, NULL, GTLV_Labels, l,TAG_END)
  48.  
  49. #define egMenuItemUnderPointer(m)    ((ULONG)GTMENUITEM_USERDATA(ItemAddress(m->IDCMPWindow->MenuStrip, m->Code)))
  50. /* Use with care */
  51. #define BufferPos(g)                            (((struct StringInfo *)(g)->gadget->SpecialInfo)->BufferPos)
  52. #define String(g)                                    (((struct StringInfo *)(g)->gadget->SpecialInfo)->Buffer)
  53. #define UndoString(g)                            (((struct StringInfo *)(g)->gadget->SpecialInfo)->UndoBuffer)
  54. #define Number(g)                                    (((struct StringInfo *)(g)->gadget->SpecialInfo)->LongInt)
  55. #define KickStart                                    (IntuitionBase->LibNode.lib_Version)
  56.  
  57. /*** Layout Macros ***/
  58. #define    egWindowHeight(t)                    ((t)->window->Height)
  59. #define    egWindowWidth(t)                    ((t)->window->Width)
  60. #define    X1(g)                                            ((g)->ng.ng_LeftEdge)
  61. #define    Y1(g)                                            ((g)->ng.ng_TopEdge)
  62. #define    W(g)                                            ((g)->ng.ng_Width)
  63. #define    H(g)                                            ((g)->ng.ng_Height)
  64. #define    X2(g)                                            (X1(g)+W(g))
  65. #define    Y2(g)                                            (Y1(g)+H(g))
  66. #define    EG_StringBorder                        12
  67. #define    EG_LabelSpaceH                        8
  68. #define    EG_LabelSpaceV                        6
  69. #define    EG_LabelSpace                            EG_LabelSpaceH
  70. #define EG_CycleWidth                            55
  71. #define EG_GetfileWidth                        17
  72. #define EG_GetdirWidth                        20
  73. #define EG_PopupWidth                            16
  74.  
  75. /* KEY CODES */
  76. #define RETURN_KEY                                13
  77. #define ESC_KEY                                        27
  78.  
  79. #define    MAXCHARS                                    256
  80.  
  81. #define    EG_LISTVIEW_NONE                    65535
  82. #define    EG_LISTVIEW_FIRST                    0
  83. #define    EG_LISTVIEW_LAST                    -2
  84. #define    EG_LISTVIEW_ACTIVE                -3
  85.  
  86. /* task status */
  87. #define    STATUS_CLOSED                            0
  88. #define    STATUS_OPEN                                1
  89. #define    STATUS_RESET                            2
  90.  
  91. /* egGadget flags */
  92. #define    EG_DISABLED                                    1        // gadget is disabled
  93. #define    EG_LISTVIEWARROWS                        2        // add control by cursor up/down
  94. #define    EG_READONLY                                    4        // this gadget is read-only
  95. #define    EG_PLACETEXT_LEFT                        8        // Left-align text on left side
  96. #define    EG_PLACETEXT_RIGHT                    16    // Right-align text on right side
  97.  
  98. /* egTask flags */
  99. #define    TASK_NOSIZE                                    1        // init task size
  100. #define    TASK_BLOCKED                                2        // set when a task is blocked
  101. #define    TASK_GHOSTWHENBLOCKED                4        // will ghost window when blocked
  102.  
  103. /* eg flags */
  104. #define    EG_ICONIFIED                                1        // application is iconified
  105. #define    EG_RESET                                        2        // application is about to or has reset itself
  106. #define    EG_OPENHELPDOCUMENT                    4        // reopen helpdocument when application resets itself
  107.  
  108. /* for future use */
  109. #define    EG_LIST                                            (-1)
  110. #define    EG_SUBLIST                                    (-2)
  111.  
  112. /* Message types */
  113. #define    EG_INTUIMSG                                    (NT_USER-1)
  114.  
  115. /* IDCMPS */
  116. #define    EGIDCMP_NOTIFY                            4294967293
  117.  
  118. /*** GLOBALS *************************************************************************/
  119. struct egImageExt
  120. {
  121.     struct BitMap        ImageBitMap;
  122.     struct BitMap        BitMap;
  123.  
  124.     struct Image        Image1;
  125.     struct Image        Image2;
  126. };
  127.  
  128. struct egGadget
  129. {
  130.     ULONG                            kind;
  131.     struct NewGadget    ng;
  132.     struct Gadget            *gadget;
  133.     UBYTE                            key,
  134.                                         *helpnode;
  135.     STRPTR                        *labels;
  136.     struct List                *list;
  137.     LONG                            active;
  138.     ULONG                            flags;
  139.     WORD                            min,
  140.                                         max;
  141.  
  142.     struct egImageExt    *imageext;
  143.     struct egGadget        *NextGadget,
  144.                                         *link,
  145.                                         *group;
  146. };
  147.  
  148. struct egCoords
  149. {
  150.     WORD    LeftEdge, TopEdge, Width, Height;
  151. };
  152.  
  153. struct egTask
  154. {
  155.     APTR                                VisualInfo;
  156.     struct DrawInfo            *dri;
  157.     struct Screen                *screen;
  158.     struct Window             *window;
  159.     struct Gadget                *glist;
  160.     struct egCoords            coords;
  161.     WORD                                oldWidth,
  162.                                             oldHeight;
  163.     UBYTE                                status;
  164.     struct egGadget            *eglist,
  165.                                             *activegad;
  166.  
  167.     UBYTE                                activekey;
  168.     struct egTask                *nexttask;
  169.     struct Requester        *req;
  170.     ULONG                                reqcount;
  171.     APTR                                eg_UserData;
  172.     struct Requester        *lock;
  173.     ULONG                                flags;
  174.     struct EasyGadgets    *eg;
  175.     void                                *refreshfunc,
  176.                                             *renderfunc,
  177.                                             *handlefunc,
  178.                                             *openfunc,
  179.                                             *closefunc,
  180.                                             *openguifunc,
  181.                                             *closeguifunc;
  182.     struct Gadget                *iconifygadget;
  183.     UBYTE                                *helpnode;
  184.     APTR                                screenhandle,
  185.                                             pubhandle;
  186. };
  187.  
  188. struct EasyGadgets
  189. {
  190.     struct Screen                    *screen;
  191.     struct Window                    *Window;
  192.     struct RastPort                RPort;
  193.     struct TextFont                *font;
  194.     struct DrawInfo                *dri;
  195.  
  196.     struct Gadget                    *gad;
  197.     struct NewGadget            ng;
  198.     struct egGadget                *eggad, *group;
  199.     struct egTask                    *tmptask;
  200.     ULONG                                 GadgetKind;
  201.  
  202.     struct MsgPort                *msgport;
  203.     struct IntuiMessage        *msg;
  204.     struct egTask                    *tasklist;
  205.  
  206.     WORD    VInside,    HInside, HSpace, VSpace,
  207.                 GroupBorderLeft, GroupBorderTop, GroupBorderRight, GroupBorderBottom,
  208.                 SliderWidth,        SliderHeight,
  209.                 CheckboxWidth,    CheckboxHeight,
  210.                 MXWidth,                MXHeight,
  211.                 LeftMargin,            TopMargin, RightMargin, BottomMargin, BottomMarginNoSize,
  212.                 FontHeight,
  213.                 DefaultHeight,
  214.                 ScreenBarHeight;
  215.  
  216.     UBYTE                                    *helpdoc,
  217.                                                 *lasthelpnode,
  218.                                                 *basename;
  219.     APTR                                    AG_Context;
  220.     struct NewAmigaGuide    AG_NewGuide;
  221.     UBYTE                                    GuideMsg[MAXCHARS];
  222.     ULONG                                    AmigaGuideSignal;
  223.  
  224.     struct AppIcon                *appicon;
  225.     struct DiskObject            *diskobj;
  226.  
  227.     ULONG                                    flags;
  228.     Class                                    *iconifyclass,
  229.                                                 *groupframeclass;
  230.  
  231.     struct MsgPort                *notifyport;
  232.     APTR                                    wbhandle;
  233. };
  234.  
  235. /*** TAGS ****************************************************************************/
  236. #define    EG_TagBase                        (TAG_USER+10777)
  237.  
  238. #define EG_GROUP_KIND                    (EG_TagBase+1)
  239. #define    EG_GETFILE_KIND                (EG_TagBase+10)
  240. #define    EG_GETDIR_KIND                (EG_TagBase+11)
  241. #define    EG_POPUP_KIND                    (EG_TagBase+12)
  242. #define    EG_IMAGE_KIND                    (EG_TagBase+13)
  243. #define    EG_DUMMY_KIND                    (EG_TagBase+14)
  244.  
  245. #define    EG_GadgetID                        (EG_TagBase+1)
  246. #define    EG_GadgetText                    (EG_TagBase+2)
  247. #define    EG_GadgetFrame                (EG_TagBase+3)
  248. #define    EG_LeftEdge                        (EG_TagBase+4)
  249. #define    EG_TopEdge                        (EG_TagBase+5)
  250. #define    EG_Width                            (EG_TagBase+6)
  251. #define    EG_Height                            (EG_TagBase+7)
  252. #define    EG_GadgetKind                    (EG_TagBase+8)
  253. #define    EG_VisualInfo                    (EG_TagBase+9)
  254. #define    EG_TextAttr                        (EG_TagBase+10)
  255. #define    EG_Flags                            (EG_TagBase+11)
  256. #define    EG_Window                            (EG_TagBase+12)
  257. #define    EG_ParentGadget                (EG_TagBase+13)
  258.  
  259. #define    EG_PlaceLeft                    (EG_TagBase+14)
  260. #define    EG_PlaceRight                    (EG_TagBase+15)
  261. #define    EG_PlaceBelow                    (EG_TagBase+16)
  262. #define    EG_PlaceOver                    (EG_TagBase+17)
  263.  
  264. #define    EG_AlignLeft                    (EG_TagBase+18)
  265. #define    EG_AlignTop                        (EG_TagBase+19)
  266. #define    EG_AlignRight                    (EG_TagBase+20)
  267. #define    EG_AlignBottom                (EG_TagBase+21)
  268.  
  269. #define    EG_AlignCentreH                (EG_TagBase+22)
  270. #define    EG_AlignCentreV                (EG_TagBase+23)
  271.  
  272. #define    EG_CloneWidth                    (EG_TagBase+24)
  273. #define    EG_CloneHeight                (EG_TagBase+25)
  274. #define    EG_CloneSize                    (EG_TagBase+26)
  275.  
  276. #define    EG_PlaceWindowLeft        (EG_TagBase+27)
  277. #define    EG_PlaceWindowRight        (EG_TagBase+28)
  278. #define    EG_PlaceWindowTop            (EG_TagBase+29)
  279. #define    EG_PlaceWindowBottom    (EG_TagBase+30)
  280.  
  281. #define    EG_HSpace                            (EG_TagBase+31)
  282. #define    EG_VSpace                            (EG_TagBase+32)
  283.  
  284. #define    EG_HelpNode                        (EG_TagBase+33)
  285. #define    EG_HelpDocument                (EG_TagBase+34)
  286. #define    EG_VanillaKey                    (EG_TagBase+35)
  287.  
  288. #define    EG_Basename                        (EG_TagBase+36)
  289. #define EG_Link                                (EG_TagBase+37)
  290. #define EG_Arrows                            (EG_TagBase+38)
  291.  
  292. #define    EG_DefaultHeight            (EG_TagBase+39)
  293. #define    EG_DefaultWidth                (EG_TagBase+40)
  294.  
  295. #define    EG_InitialCentre            (EG_TagBase+41)
  296. #define    EG_InitialUpperLeft        (EG_TagBase+42)
  297. #define    EG_Menu                                (EG_TagBase+43)
  298. #define    EG_Blocked                        (EG_TagBase+44)
  299. #define    EG_IDCMP                            (EG_TagBase+45)
  300. #define    EG_RefreshFunc                (EG_TagBase+46)
  301. #define    EG_RenderFunc                    (EG_TagBase+47)
  302. #define    EG_CloseFunc                    (EG_TagBase+48)
  303. #define    EG_HandleFunc                    (EG_TagBase+49)
  304. #define    EG_OpenFunc                        (EG_TagBase+50)
  305. #define    EG_OpenGUIFunc                (EG_TagBase+51)
  306. #define    EG_CloseGUIFunc                (EG_TagBase+52)
  307.  
  308. #define    EG_ImageWidth                    (EG_TagBase+53)
  309. #define    EG_ImageHeight                (EG_TagBase+54)
  310. #define    EG_Image                            (EG_TagBase+55)
  311. #define    EG_ImageDepth                    (EG_TagBase+56)
  312.  
  313. #define    GTLV_SelectedNode            (EG_TagBase+57)
  314.  
  315. #define    EG_AppIcon                        (EG_TagBase+58)
  316. #define    EG_IconifyGadget            (EG_TagBase+59)
  317.  
  318. #define    EG_Title                            (EG_GadgetText)
  319. #define    EG_ThickFrame                    (EG_TagBase+60)
  320. #define    EG_PlaceTitleLeft            (EG_TagBase+61)
  321. #define    EG_PlaceTitleRight        (EG_TagBase+62)
  322. #define    EG_Highlight                    (EG_TagBase+63)
  323. #define    EG_Shadow                            (EG_TagBase+64)
  324. #define    EG_Font                                (EG_TagBase+65)
  325.  
  326. #define    EG_GhostWhenBlocked        (EG_TagBase+66)
  327.  
  328. #define    EG_LendMenu                        (EG_TagBase+67)
  329. #define    EG_HelpMenu                        (EG_TagBase+68)
  330.  
  331. #define    EG_WorkbenchNotify        (EG_TagBase+69)
  332. #define    EG_ScreenNotify                (EG_TagBase+70)
  333. #define    EG_PubScreenNotify        (EG_TagBase+71)
  334.  
  335. #endif
  336.